// 封装和文章相关的接口
import request from '@/utils/request'

// 获取文章接口
export const getList = function(params){
    return request({
        method:'GET',
        url:'/mp/v1_0/articles',
        params
    });
}


// 获取文章频道接口
export const getChannel = function(){
    return request({
        method:'GET',
        url:'/mp/v1_0/channels'
    });
}

// 删除文章接口
export const delArticle = function(id){
    return request({
        method:'DELETE',
        url:`/mp/v1_0/articles/${id}`
    });
}

// 添加文章接口
export const pubArticle = function(draft,data){
    return request({
        method:'POST',
        url:'/mp/v1_0/articles',
        params:{
            draft
        },
        data,
    });
}

// 获取当前要编辑的文章
export const getCurArticle = function(id){
    return request({
        method:'GET',
        url:`/mp/v1_0/articles/${id}`,
    });
}

// 编辑文章接口
export const editArticle = function(id,draft,data){
    return request({
        method:'PUT',
        url:`/mp/v1_0/articles/${id}`,
        params:{
            draft,
        },
        data
    });
}


// 修改评论状态接口
export const changeComment = function(params,data){
    return request({
        method:'PUT',
        url:'/mp/v1_0/comments/status',
        params,
        data
    });
}
